<%@LANGUAGE="VBSCRIPT" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Save Article</title>
</head>

<body>

<% 
set conn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
filepath=server.MapPath("access/backend/help.mdb")
conn.open "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filepath
Smode=request.form("mode")
id=request.form("id")
if Smode="edit" then
	sql="select * from HelpTopics where id=" & id
	rs.open sql,conn,1,2
	if request.form("catagory")="Header" then
		rs("parent")=0
	else
		rs("parent")=request.form("parent")
	end if
	rs("catagory")=request.form("catagory")
	rs("body")=replace(request.form("article"),"|",vbcrlf)
	rs("title")=request.form("title")
	rs.update
	rs.close
	msg=request.form("catagory") & " '" & request.form("title") & "' successfully updated!"
	set rs=nothing
end if
if Smode="" then
	sql="select top 1 * from HelpTopics"
	rs.open sql,conn,1,2
	rs.addnew
	if request.form("catagory")="Header" then
		rs("parent")=0
	else
		rs("parent")=request.form("parent")
	end if
	rs("catagory")=request.form("catagory")
	rs("body")=replace(request.form("article"),"|",vbcrlf)
	rs("title")=request.form("title")
	rs.update
	rs.close
	set rs=nothing
	msg="new " & request.form("catagory") & " '" & request.form("title") & "' successfully saved!"
end if

set conn=nothing
%>
<script type="text/vbscript">
msgbox "<%=msg %>"
parent.parent.window.location.reload()
</script>
</body>
</html>
